﻿<!DOCTYPE HTML>
<html>
<head>
<#include "/script.ftl">
<link rel="stylesheet" type="text/css" href="../static/eth/css/customer.css" />
<script type="text/javascript" src="../static/eth/js/jElass.js"></script>
<script type="text/javascript" src="../static/eth/js/jElassExec.js"></script>
<title>用户详情</title>
</head>
<body id="body" class="common_body">
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i> 首页
		<span class="c-gray en">&gt;</span>账户
		<span class="c-gray en">&gt;</span> 部门管理
	</nav>
	<div class="page-container">
		<form id="form" action="list" autocomplete="off">
			<input type="hidden"  name="pageIndex" id="pageIndex" value="${page.curIndex!''}"/>
			<input type="hidden"  name="pageSize" id="pageSize" value="${page.pageSize!''}" />
			<input type="hidden"  name="rowsCount" id="rowsCount" value="${page.rowsCount!''}" />
			<div class="customer_box text-c">
				<div class="customer_item1 text-c" style="margin-left:30px">
					<label>部门名称</label>
					<input type="text" name="deptName" value="${cond.deptName!''}" onClick="DeptId(deptName,deptId)" class="input-text ">
					<input type="hidden" name="deptId" id="deptId" value="${cond.deptId!''}">
				</div>
				<div class="customer_item4 text-c"><input type="button" onClick="query_submit()" value="查询" name="" class="btn btn-primary radius"></div>
				<div class="f-r mr-20"><input type="button" onClick="dept_edit('<center><strong>部门保存</strong></center>','editPage','800','270')" value="添加部门" name="" class="btn btn-primary radius"></div>
			</div>
			<div class="customer_box1"> 
				<table class="table table-hover panel panel-secondary">
					<thead class="panel-header text-c">
						<tr>
							<th width="20%">序号</th>
							<th width="20%">部门名称</th>
							<th width="20%">部门负责人</th>
							<th width="40%">操作</th>
						</tr>
					</thead>
					<tbody class="panel-body text-c">
						<#list page.items! as dept>
							<tr ondblclick="dept_edit('<center><strong>部门保存</strong></center>','editPage?deptId=${dept.deptId!}','800','270')">
								<td>${page.pageSize * (page.curIndex-1) + dept_index+1}</td>
								<td>${dept.deptName!''}</td>
								<td>${dept.manager!''}</td>
								<td>
									<input type="button" value="编辑" onClick="dept_edit('<center><strong>部门保存</strong></center>','editPage?deptId=${dept.deptId!}','800','270')" class="btn btn-primary radius">
									<input type="button" value="删除" onClick="dept_delete('delete?deptId=${dept.deptId!}')" class="btn btn-danger radius ml-10">
								</td>
							</tr>
						</#list>
					</tbody>
				</table>
			</div>
			<div id="div" class="cl">
				<div id="Pagination" class="pagination mt-20"></div>
			</div>
		</form>
	</div>
</body>
<script>
$(function(){
	$(".customer_head").on("click","span",function(){
		$(this).addClass("current_span").siblings().removeClass("current_span");
		$(".customer_content").hide().eq($(this).index()).show();
	});
	
})

function query_submit(){
	$("div.customer_item1").find("input[type='hidden']").each(function(index,dom){
		if($(dom).prev().val() == ''){
				$(dom).val('');
		}				
	});
	$('#pageIndex').val(1);
	$('#form').submit()
}

function dept_delete(urlStr){
	if(!confirm("确定要删除？")){
		return;
	}
	$.ajax({
		type : 'get',  
		contentType : 'application/json',  
		url : urlStr,  
		success : function(data) {
			var rsult = jQuery.parseJSON(data);
			if (rsult.success) {
				alert("删除部门成功！");
				window.location.reload();
			} else {
				alert("删除部门失败!" + rsult.message);
			}
 		},  
		error : function(data) {  
        	alert("系统错误！")  
		}
	});
}
function dept_edit(title,url,w,h){
	layer_show(title,url,w,h);	
}
</script>
</html>